package com.ym.user.controller;

import com.ym.user.entity.TestEntity;
import com.ym.utils.restful.AjaxJson;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

@Api(value = "/TestController", tags = {"测试"})
@RestController
@RequestMapping("/TestController")
public class TestController {

    /**
     * @return
     */
    @ApiOperation(value = "测试方法一", notes = "描述：测试单元方法返回固定值", httpMethod = "POST")
    @RequestMapping(value = "/get/test", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public AjaxJson selectAll(@RequestBody TestEntity testEntity) {
        AjaxJson ajaxJson = new AjaxJson();
        Map map = new HashMap<>();
        map.put("name", "晨曦");
        map.put("age", "25");
        return ajaxJson.Success(map);
    }

    @Data
    @Accessors(chain = true)
    static class PurchaseInvoice {
        private Integer purchaseInvoiceId;
        private String purchaseInvoiceNum;
        private String slat;
    }

    public void makeCheak(List<PurchaseInvoice> mysqlPurchaseInvoiceList, List<PurchaseInvoice> oraclePurchaseInvoiceList) {
        //执行对比补充单据
        //List<Integer> mysqlList = mysqlPurchaseInvoiceList.stream().map(PurchaseInvoice::getPurchaseInvoiceId).collect(Collectors.toList());
       // List<Integer> oracleList = oraclePurchaseInvoiceList.stream().map(PurchaseInvoice::getPurchaseInvoiceId).collect(Collectors.toList());
        //获取不同
        //List<Integer> reduce1 = mysqlList.stream().filter(item -> !oracleList.contains(item)).collect(Collectors.toList());

        //List<PurchaseInvoice> reduce1 = mysqlPurchaseInvoiceList.stream().filter(item -> !oraclePurchaseInvoiceList.contains(item)).collect(Collectors.toList());

        List<PurchaseInvoice> reduce1 = mysqlPurchaseInvoiceList.stream().filter(mp -> oraclePurchaseInvoiceList.stream().noneMatch(op -> op.getPurchaseInvoiceId().equals(mp.getPurchaseInvoiceId()))).collect(Collectors.toList());

        reduce1.parallelStream().forEach(System.out::println);
    }


    public static void main(String[] args) {


        BigDecimal decimal =new BigDecimal(0.00000100).setScale(8, BigDecimal.ROUND_HALF_UP);
        double dou= 0.00000010D;
        //double que = 0;
        System.out.println(decimal.toString());
        System.out.println(dou);
//        Date date =new Date(1607702400000L);
//
//        /*List<String> list1 = new ArrayList();
//
//        list1.add("1111");
//        list1.add("2222");
//        list1.add("3333");
//        list1.add("4444");
//
//        List<String> list2 = new ArrayList();
//        list2.add("3333");
//        list2.add("1111");
//        list2.add("2222");
//
//        List<String> reduce1 = list1.stream().filter(item -> !list2.contains(item)).collect(Collectors.toList());
//        System.out.println("---得到差集 reduce1 (list1 - list2)---");
//        reduce1.parallelStream().forEach(System.out :: println);*/
//        PurchaseInvoice purchaseInvoice1 = new PurchaseInvoice().setPurchaseInvoiceId(101).setPurchaseInvoiceNum("CX101").setSlat("a");
//        PurchaseInvoice purchaseInvoice2 = new PurchaseInvoice().setPurchaseInvoiceId(102).setPurchaseInvoiceNum("CX102").setSlat("b");
//        PurchaseInvoice purchaseInvoice3 = new PurchaseInvoice().setPurchaseInvoiceId(103).setPurchaseInvoiceNum("CX103").setSlat("v");
//        PurchaseInvoice purchaseInvoice4 = new PurchaseInvoice().setPurchaseInvoiceId(104).setPurchaseInvoiceNum("CX104").setSlat("d");
//        PurchaseInvoice purchaseInvoice5 = new PurchaseInvoice().setPurchaseInvoiceId(105).setPurchaseInvoiceNum("CX105").setSlat("w");
//        PurchaseInvoice purchaseInvoice6 = new PurchaseInvoice().setPurchaseInvoiceId(106).setPurchaseInvoiceNum("CX106").setSlat("s");
//
//
//        PurchaseInvoice purchaseInvoice11 = new PurchaseInvoice().setPurchaseInvoiceId(101).setPurchaseInvoiceNum("CX101").setSlat("u");
//        PurchaseInvoice purchaseInvoice12 = new PurchaseInvoice().setPurchaseInvoiceId(102).setPurchaseInvoiceNum("CX102").setSlat("i");
//        PurchaseInvoice purchaseInvoice13 = new PurchaseInvoice().setPurchaseInvoiceId(1031).setPurchaseInvoiceNum("CX103").setSlat("o");
//
//
//        List<PurchaseInvoice> mysqlPurchaseInvoiceList = new ArrayList<>();
//        mysqlPurchaseInvoiceList.add(purchaseInvoice1);
//        mysqlPurchaseInvoiceList.add(purchaseInvoice2);
//        mysqlPurchaseInvoiceList.add(purchaseInvoice3);
//        mysqlPurchaseInvoiceList.add(purchaseInvoice4);
//        mysqlPurchaseInvoiceList.add(purchaseInvoice5);
//        //mysqlPurchaseInvoiceList.add(purchaseInvoice6);
//
//        List<PurchaseInvoice> oraclePurchaseInvoiceList = new ArrayList<>();
//
//        oraclePurchaseInvoiceList.add(purchaseInvoice11);
//        oraclePurchaseInvoiceList.add(purchaseInvoice12);
//        oraclePurchaseInvoiceList.add(purchaseInvoice13);
//        oraclePurchaseInvoiceList.add(purchaseInvoice4);
//
//        TestController entity = new TestController();
//        entity.makeCheak(mysqlPurchaseInvoiceList, oraclePurchaseInvoiceList);

    }



}
